package cn.study.luckyapp.rule.command;

import cn.study.luckyapp.assembler.RuleAssembler;
import cn.study.luckyclient.dto.RuleAddCmd;
import cn.study.luckyclient.dto.data.RuleVo;
import cn.study.luckydomain.gateway.RuleGateway;
import cn.study.luckydomain.rule.RuleEntity;
import com.alibaba.cola.dto.Command;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@AllArgsConstructor
public class RuleAddCmdExe{
    private final RuleGateway ruleGateway;
    public RuleVo execute(RuleAddCmd cmd){
        RuleEntity ruleEntity = RuleAssembler.toEntity(cmd);
        RuleEntity add = ruleGateway.add(ruleEntity);
        return RuleAssembler.toRuleVo(add);
    }
}
